package com.buybuyyi.stylistcrm.resource.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import stylistcrm.core.services.order.enums.EnumExceptionCode;
import stylistcrm.core.services.order.exception.BizException;
import stylistcrm.core.services.user.User;
import stylistcrm.core.services.user.service.UserService;

/**
 * Created by yanwc on 2016/8/17.
 */
public class DefaultController {
    /**
     * 用户管理service
     */
    @Autowired
    protected UserService userService;

    /**
     * 校验登录
     * @return
     * @throws BizException
     */
    protected Long checkLogin() throws BizException {
        User user=userService.getCurrentUser();
        if(null==user||null==user.getId() || user.getMemberId()<=0){
            throw new BizException(EnumExceptionCode.EC0005);
        }
        return user.getId();
    }
}
